/*     */ package com.qmsk.business.info.userEmail.controller;
/*     */ 
/*     */ import com.qmsk.business.info.userEmail.dao.UserEmailDAO;
/*     */ import com.utils.gson.in.GsonHeadOneRow;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.sql.SQLException;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/userEmail"})
/*     */ public class UserEmailController
/*     */ {
/*  27 */   private static final Logger logger = Logger.getLogger(UserEmailController.class);
/*     */ 
/*     */   @Autowired
/*     */   private UserEmailDAO dao;
/*     */ 
/*     */   @RequestMapping(value={"find/userId/{userId}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOfManuId(HttpServletRequest request, HttpServletResponse response, @PathVariable("userId") Integer userId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  37 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  39 */       GsonEbRst gsonEbRst = this.dao.getGsonOfUserId(userId, nPageIdx, nPageSize);
/*  40 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  42 */       ResponseUtils.setErrorMsgResponse(
/*  43 */         RequestUtils.getFindDataErrorMessage(request), response);
/*  44 */       logger.error(e);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*  60 */     String sGsonInData = request.getParameter("data");
/*     */     try {
/*  62 */       int nResult = this.dao.insertJsonOneRow(sGsonInData);
/*  63 */       DbConnection.commit();
/*  64 */       ResponseUtils.setSqlResultResponse(nResult, 
/*  65 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/*  66 */         response);
/*     */     } catch (Exception e) {
/*  68 */       DbConnection.rollback();
/*  69 */       logger.error(e);
/*  70 */       ResponseUtils.setErrorMsgResponse(
/*  71 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/*  72 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*  88 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/*  90 */       String[] strParams = id.split(",");
/*  91 */       int nResult = this.dao.deleteParams(strParams);
/*  92 */       ResponseUtils.setSqlResultResponse(nResult, 
/*  93 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/*  94 */         response);
/*  95 */       DbConnection.commit();
/*     */     } catch (Exception e) {
/*  97 */       DbConnection.rollback();
/*  98 */       logger.error(e);
/*  99 */       ResponseUtils.setErrorMsgResponse(
/* 100 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 101 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"edit"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void update(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 117 */     String id = request.getParameter("id");
/* 118 */     String sGsonInData = request.getParameter("data");
/*     */     try {
/* 120 */       GsonHeadOneRow g = GsonHeadOneRow.jsonStrToObject(sGsonInData);
/* 121 */       if (g == null) {
/* 122 */         ResponseUtils.setErrorMsgResponse(
/* 123 */           RequestUtils.getReadJsonDataErrorMessage(request), 
/* 124 */           response);
/*     */       } else {
/* 126 */         int nResult = this.dao.updateJsonOneRow(g, id);
/* 127 */         ResponseUtils.setSqlResultResponse(nResult, 
/* 128 */           RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 129 */           response);
/*     */       }
/* 131 */       DbConnection.commit();
/*     */     } catch (Exception e) {
/* 133 */       DbConnection.rollback();
/* 134 */       logger.error(e);
/* 135 */       ResponseUtils.setErrorMsgResponse(
/* 136 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 137 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.info.userEmail.controller.UserEmailController
 * JD-Core Version:    0.5.3
 */